#include<iostream>
#include<string.h>
using namespace std;
int main()
{
  string s2(10,'c');
  string s1("hello world!!");
  s1.push_back('A');
  s1.insert(1,"B");
  s1.insert(2,"BB");
  s1.insert(s1.end(),'B');
  s1.insert(s1.begin(),'S');
  s1.append(s2);
  s1.pop_back();
  s1.erase(0,3);
  s1.push_back('Y');
  s1.erase(s1.end()-1);
  s1.erase(s1.begin());
  s1.erase(s1.begin()+2,s1.end());
  s1.resize(20,'s');
  s1.resize(10);
  s1.reserve(100);
  s1.reserve(30);
  s1.reserve(1);
  for(auto& e:s1)
  {
   cout<<e;
  }
  cout<<endl;

  string::iterator it = s1.begin();
  while(it!=s1.end())
  {

    cout<<*it;
    it++;
  }
  cout<<endl;
  string::reverse_iterator rit = s1.rbegin();

  while(rit!=s1.rend())
  {

    cout<<*rit;
    rit++;
  }
  
 
  cout<<endl;
  //s1.reserve();
  cout<<s1<<endl;;
  
  char str[10] = {0};
  size_t len = s1.copy(str,4,2);
  str[len] = '\0';
  cout<<len<<endl;
  cout<<str<<endl; 
  cout<<s1.size()<<"  "<<s1.length()<<endl;
  cout<<s1.max_size()<<endl;
  cout<<s1.compare(s2)<<endl;
  cout<<s1<<"  "<<s2<<endl;;
  cout<<s1.capacity()<<endl; 

  string s3;
  //cin>>s3;//中间有空格截断
  //cout<<s3<<endl;
  
 // getline(cin, s3);
  getline(cin,s3,'s');//直到读取到分隔符delim或换行符’\n’为止
  cout<<s3<<endl;


  return 0;
}
